package ug.co.icom.kyazze.healthticket.tabswipeadapter;

import android.app.ActionBar;
import android.app.ActionBar.TabListener;
import android.content.Context;
import android.support.v4.view.ViewPager;


public class BoilerPlateCodeSwipeTabs {
	private static String[] tabs = { "Home", "Dr Consultations", "Current Medications" };
	
	public static void initialization(ViewPager vp, final ActionBar ab, Context context){
		// Adding Tabs
				for (String tab_name : tabs) {
					ab.addTab(ab.newTab().setText(tab_name)
							.setTabListener((TabListener) context));
				}

				/**
				 * on swiping the viewpager make respective tab selected
				 * */
				vp.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

					@Override
					public void onPageSelected(int position) {
						// on changing the page
						// make respected tab selected
						ab.setSelectedNavigationItem(position);
					}

					@Override
					public void onPageScrolled(int arg0, float arg1, int arg2) {
					}

					@Override
					public void onPageScrollStateChanged(int arg0) {
					}
				});

			}
		
	}


